/*
2021-8-4
https://www.acwing.com/problem/content/108/
*/
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n,m;
        cin>>m>>n;
        cout<<m<<' '<<(n+1)/2<<endl;
        priority_queue<int>down;
        priority_queue<int,vector<int>,greater<int>>up;
        
        int cnt=0;
        
        for(int i=1;i<=n;i++)
        {
            int x;
            cin>>x;
            
            if(down.empty() || down.top()>=x) down.push(x);
            else up.push(x);
            
            if(down.size() > up.size()+1) up.push(down.top()),down.pop();
            if(up.size() > down.size()) down.push(up.top()),up.pop();
            
            if(i&1) 
            {
                printf("%d ",down.top());
                if(++cnt%10==0) puts("");
            }
            
        }
        if(cnt%10) puts("");
    }
    return 0;
}
